package com.util.dao;

import java.util.List;

/**
 * @ClassName test
 * @Description TODO
 * @Author Kx
 * @Date 2025/3/31 15:30
 * @Version 1.0
 */
public class Test {
    BaseDao baseDao = new BaseDao();
    @org.junit.Test
    public void test1(){
        String sql = "SELECT c_id AS cId, c_name AS cName, c_number AS cNumber, c_price AS cPrice, c_status AS cStatus FROM commodity";
        List<Commodity> commodities = baseDao.baseQueryList(Commodity.class, sql);

        for (Commodity commodity : commodities) {
            System.out.println(commodity);
        }
    }

    @org.junit.Test
    public void test2(){
        String sql = "SELECT c_id AS cId, c_name AS cName, c_number AS cNumber, c_price AS cPrice, c_status AS cStatus FROM commodity where c_id = ?";

        Commodity commodity = baseDao.baseQuery(Commodity.class, sql, 1);

        System.out.println(commodity);
    }

    @org.junit.Test
    public void test3(){
        String sql = "INSERT INTO commodity (c_name, c_number, c_price, c_status) VALUES (?,?,?,?)";

        int i = baseDao.baseUpdate(sql, "台式电脑", "10", "8000", "0");

        System.out.println(i);
    }

    @org.junit.Test
    public void test4(){
        String sql = "SELECT c_name AS cName FROM commodity where c_id = ?";
        String cName = (String) baseDao.querySingleFieldValue(Commodity.class, sql, "cName", 1);

        System.out.println(cName);
    }
}
